import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {FetchService} from '../../../core/net/fetch.service';
import {NzMessageService, NzTreeNode} from 'ng-zorro-antd';
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
import {Router} from "@angular/router";


@Component({
  selector: 'app-project-by-address-detail',
  templateUrl: 'project-by-address-detail.component.html',
  styleUrls: ['./project-by-address-detail.component.scss']
})
export class ProjectByAddressDetailComponent implements OnInit {
  form: FormGroup;
  yearValue = 2020;
  monthPickerValue = new Date().getMonth();
  serverUrl = (window as any).environment.reportUrl;
  iframeSrc: SafeResourceUrl;
  leftListArr = [
    '（一）取水单位基本信息表',
    '（二）项目实际情况表',
    '（三）取水许可审批情况表',
    '（四）取水工程（设施）基础信息表',
    '（五）相关附件'
  ];
  activeIndex = 0;
  constructor(private fb: FormBuilder,
              private sanitizer: DomSanitizer,
              private router: Router,
              private fetchService: FetchService,
              private message: NzMessageService) {
    this.form = this.fb.group({
      a: ['张三'],
      b: ['2020-05-05'],
      c: ['15984739487'],
      d: ['青铜峡铝业股份有限公司宁东铝业分公司']
    });

  }

  ngOnInit(): void {
    const year = this.yearValue;
    const month = this.monthPickerValue + 1;
    const token = localStorage.token;
    const link = `${this.serverUrl}preview?_u=wrs:骨干排水沟.ureport.xml&_t=3,6&year=${year}&month=${month}&token=${token}`;
    this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(link);
  }

  selectChanged(i) {
    this.activeIndex = i;
    console.log(i);
  }


  back() {
    this.router.navigate(['/water-take-projects/by-address/list']);
  }
}
